﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Salomon/MP/Base.Master" AutoEventWireup="true" CodeBehind="NewsCreate.aspx.cs" Inherits="WebsiteAdmin.Salomon.News.NewsCreate" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="server">新闻创建 - 新闻</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head_Meta" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Head_Css" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Head_Script" runat="server">
	<script type="text/javascript" src="/CKEditor/CKEditor.js"></script>
	<script type="text/javascript" src="/CKFinder/CKFinder.js"></script>
	<script type="text/javascript" src="/Script/Mootools.Smoothbox.js"></script>
<script type="text/javascript" language="javascript">
    var MenuViewID = 4;
    Array.implement({
        getFirstRadio: function() {
            if (this.length == 0) {
                return null;
            }
            return this[0];
        }
    });
    window.addEvent('domready', function() {
        if (typeof (CKEDITOR) == 'undefined' || typeof (CKFinder) == 'undefined') {
            alert('加载CKEditor或CKFinder失败');
        } else {
            CKFinder.setupCKEditor(null, '/CKFinder/');
            CKEDITOR.replace('txbNewsContent');
        }

        $('submitbtn').addEvent('click', function() {
            Submit();
        });
    });


    function getContents(e) {
        var oEditor = CKEDITOR.instances[e];
        if (oEditor != null) {
            return (oEditor.getData());
        } else {
            return "";
        }
    }

    function Submit() {
        var txbNewsTitle = $('txbNewsTitle').get('value').trim();
        if (txbNewsTitle.length == 0) {
            alert('介绍标题错误');
            return false;
        }
       
        var txbKeywords = $('txbKeywords').get('value').trim();
        var txbDescription = $('txbDescription').get('value').trim();
        var txbNewsContent = getContents('txbNewsContent').trim();

        Insert(
        txbNewsTitle,
        txbKeywords,
        txbDescription,
        txbNewsContent);
    }

    function Insert(txbNewsTitle,
        txbKeywords,
        txbDescription,
        txbNewsContent) {
        LightBox.show();
        new Request.JSON({
            method: 'post',
            url: '/Salomon/News/Handler/Insert.ashx',
            data: {
                NewsTitle: txbNewsTitle,
                Keywords: txbKeywords,
                Description: txbDescription,
                NewsContent: txbNewsContent
            },
            noCache: true,
            onSuccess: function(data, text) {
                if (data.Done == 'Success') {

                    if (!confirm('添加成功！\r\n继续添加？')) {
                        document.location.href = '/Salomon/News/NewsList.aspx';
                    };
                    LightBox.remove();
                }
                else {
                    alert('添加失败');
                    LightBox.remove();
                }
            },
            onFailure: function(xhr) {
                alert(xhr.statusText);
                LightBox.remove();
            }
        }).send();
    }
    
</script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Body_Top" runat="server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Body_Content" runat="server">
      <div class="infobox">
        <h3>
        <span>新闻创建</span>
			<a href="/Salomon/News/NewsList.aspx" class="back action">返回新闻列表</a>
        </h3>
        <div class="pd05">
        <form id="myForm" action="">
		    <table border="0" cellpadding="0" cellspacing="0" class="table_form">
		        <tr>
            		<td align="right" width="100"><span class="Need">介绍标题：</span></td>
            		<td>
            			<input name="txbNewsTitle" type="text" id="txbNewsTitle" maxlength="40" size="25" value="" />
            			<i>限25个汉字</i>
            		</td>
				</tr>
				<tr>
            		<td align="right" width="100"><span class="Need">关键词：</span></td>
            		<td>
            			<input name="txbKeywords" type="text" id="txbKeywords" maxlength="50" size="50" value=""/>
            		</td>
				</tr>
				<tr>
            		<td align="right" width="100"><span class="Need">简介：</span></td>
            		<td>
            			<textarea name="txbDescription" rows="3" cols="20" id="txbDescription"></textarea>
            		</td>
				</tr>
				<tr>
					<td align="right"><span class="Need">内容：</span></td>
					<td>
						<textarea name="txbNewsContent" rows="14" cols="20" id="txbNewsContent"></textarea>
						<i>限2000汉字(4000字符)</i>
					</td>
				</tr>
		    </table>
		    <table border="0" cellpadding="0" cellspacing="0" class="table_form">
				<tr>
					<td width="100" height="40">&nbsp;</td>
					<td>
						<input id="submitbtn" type="button" value="提交" class="btn" />
						<input type="reset" value="重置" class="btn" />
					</td>
				</tr>
			</table>
		</form>
        </div>
    </div>

</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Body_Foot" runat="server"  >
</asp:Content>